<?php
namespace Application\Component;
use Doctrine\ORM\EntityManager;
use Application\Entity\City;
use Application\Component\AbstractComponent;
/**
 * CountryServcie
 *
 */
class CityComponent extends  AbstractComponent
{
    protected  $entity="Application\\Entity\\City";

	function insert($city)
	{
		$this->em->persist($city);
		$this->em->flush();
	}
	
	
	function update($city)
	{
		$this->em->persist($city);
		$this->em->flush();
	}
	
	
	
	function getAll()
	{
		$city = $this->em->getRepository($this->entity)->findAll();
		return  $city;
	}
	
	
	
	function getByCountry($code)
	{
		$city = $this->em->getRepository($this->entity)->getByCountry($code);
		return  $city;
	}
	
	function getByCountryProvince($code,$name)
	{
		$city = $this->em->getRepository($this->entity)->getByCountryProvince($code,$name);
		return  $city;
	}
	
	function getByNameCountryProvince($nameCity,$code,$name)
	{
		$city = $this->em->getRepository($this->entity)->getByNameCountry($nameCity,$code,$name);
		return  $city;
	}
}
